/*
day413 
2020.10.14 
*/
#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    int countSquares(vector<vector<int>>& matrix) {
    	int len1=matrix.size(),len2=matrix.front().size(); 
    	int res=0;
		for(int i=0;i<len1;++i)
		{
			for(int j=0;j<len2;++j)
			{
				res+=help(matrix,i,j);	
			}
		}
		return res;
    }
    
    int help(vector<vector<int>>& matrix,int x,int y)
    {
    	int len1=matrix.size(),len2=matrix.front().size();
    	int res=0;
    	if(x>len1 || y>len2)
    	{
    		return 0;
		}
		
		while(x+res<len1 && y+res<len2)
		{
			for(int i=0;i<y+res;++i)
			{
				if(matrix[x+res-1][y+i]==0)
				{
					return res-1;
				}
			}
			
			for(int i=0;i<x+res;++i)
			{
				if(matrix[x+i][y+res-1]==0)
				{
					return res-1;
				}
			}
			res++;
		}
		
		return res;
	}
};

int main()
{
	return 0;
 } 


